home *** CD-ROM | disk | FTP | other *** search
/ Aminet 48 / Aminet 48 (2002)(GTI - Schatztruhe)[!][Apr 2002].iso / Aminet / text / edit / vim60rt.lha / Vim / vim60 / doc / usr_31.txt < prev    next >
Encoding:
Text File  |  2001-09-26  |  10.0 KB  |  267 lines

  1. *usr_31.txt*    For Vim version 6.0.  Last change: 2001 Sep 03
  2.  
  3.              VIM USER MANUAL - by Bram Moolenaar
  4.  
  5.                   Exploiting the GUI
  6.  
  7.  
  8. Vim works well in a terminal, but the GUI has a few extra items.  A file
  9. browser can be used for commands that use a file.  A dialog to make a choice
  10. between alternatives.  Use keyboard shortcuts to access menu items quickly.
  11.  
  12. |31.1|    The file browser
  13. |31.2|    Confirmation
  14. |31.3|    Menu shortcuts
  15. |31.4|    Vim window position and size
  16. |31.5|    Various
  17.  
  18.      Next chapter: |usr_40.txt|  Make new commands
  19.  Previous chapter: |usr_30.txt|  Editing programs
  20. Table of contents: |usr_toc.txt|
  21.  
  22. ==============================================================================
  23. *31.1*    The file browser
  24.  
  25. When using the File/Open... menu you get a file browser.  This makes it easier
  26. to find the file you want to edit.  But what if you want to split a window to
  27. edit another file?  There is no menu entry for this.  You could first use
  28. Window/Split and then File/Open..., but that's more work.
  29.    Since you are typing most commands in Vim, opening the file browser with a
  30. typed command is possible as well.  To make the split command use the file
  31. browser, prepend "browse": >
  32.  
  33.     :browse split
  34.  
  35. Select a file and then the ":split" command will be executed with it.  If you
  36. cancel the file dialog nothing happens, the window isn't split.
  37.    You can also specify a file name argument.  This is used to tell the file
  38. browser where to start.  Example: >
  39.  
  40.     :browse split /etc
  41.  
  42. The file browser will pop up, starting in the directory "/etc".
  43.  
  44. The ":browse" command can be prepended to just about any command that opens a
  45. file.
  46.    If no directory is specified, Vim will decide where to start the file
  47. browser.  By default it uses the same directory as the last time.  Thus when
  48. you used ":browse split" and selected a file in "/usr/local/share", the next
  49. time you use a ":browse" it will start in "/usr/local/share" again.
  50.    This can be changed with the 'browsedir' option.  It can have one of three
  51. values:
  52.  
  53.     last        Use the last directory browsed (default)
  54.     buffer        Use the same directory as the current buffer
  55.     current        use the current directory
  56.  
  57. For example, when you are in the directory "/usr", editing the file
  58. "/usr/local/share/readme", then the command: >
  59.  
  60.     :set browsedir=buffer
  61.     :browse edit
  62.  
  63. Will start the browser in "/usr/local/share".  Alternatively: >
  64.  
  65.     :set browsedir=current
  66.     :browse edit
  67.  
  68. Will start the browser in "/usr".
  69.  
  70.     Note:
  71.     To avoid using the mouse, most file browsers offer using key presses
  72.     to navigate.  Since this is different for every system, it is not
  73.     explained here.  Vim uses a standard browser when possible, your
  74.     system documentation should contain an explanation on the keyboard
  75.     shortcuts somewhere.
  76.  
  77. When you are not using the GUI version, you could use the file explorer window
  78. to select files like in a file browser.  However, this doesn't work for the
  79. ":browse" command.  See |file-explorer|.
  80.  
  81. ==============================================================================
  82. *31.2*    Confirmation
  83.  
  84. Vim protects you from accidentally overwriting a file and other ways to lose
  85. changes.  If you do something that might be a bad thing to do, Vim produces an
  86. error message and suggests appending ! if you really want to do it.
  87.    To avoid retyping the command with the !, you can make Vim give you a
  88. dialog.  You can then press "OK" or "Cancel" to tell Vim what you want.
  89.    For example, you are editing a file and made changes to it.  You start
  90. editing another file with: >
  91.  
  92.     :confirm edit foo.txt
  93.  
  94. Vim will pop up a dialog that looks something like this:
  95.  
  96.     +-----------------------------------+
  97.     |                    |
  98.     |   ?    Save changes to "bar.txt"?  |
  99.     |                    |
  100.     |   YES   NO         CANCEL     |
  101.     +-----------------------------------+
  102.  
  103. Now make your choice.  If you do want to save the changes, select "YES".  If
  104. you want to lose the changes for ever: "NO".  If you forgot what you were
  105. doing and want to check what really changed use "CANCEL".  You will be back in
  106. the same file, with the changes still there.
  107.  
  108. Just like ":browse", the ":confirm" command can be prepended to most commands
  109. that edit another file.  They can also be combined: >
  110.  
  111.     :confirm browse edit
  112.  
  113. This will produce a dialog when the current buffer was changed.  Then it will
  114. pop up a file browser to select the file to edit.
  115.  
  116.     Note:
  117.     In the dialog you can use the keyboard to select the choice.  Mostly
  118.     the <Tab> key and the cursor keys change the choice.  Pressing <Enter>
  119.     selects the choice.  This depends on the system though.
  120.  
  121. When you are not using the GUI, the ":confirm" command works as well.  Instead
  122. of popping up a dialog, Vim will print the message at the bottom of the Vim
  123. window and ask you to press a key to make a choice. >
  124.  
  125.     :confirm edit main.c
  126. <    Save changes to "Untitled"? ~
  127.     [Y]es, (N)o, (C)ancel:  ~
  128.  
  129. You can now press the single key for the choice.  You don't have to press
  130. <Enter>, unlike other typing on the command line.
  131.  
  132. ==============================================================================
  133. *31.3*    Menu shortcuts
  134.  
  135. The keyboard is used for all Vim commands.  The menus provide a simple way to
  136. select commands, without knowing what they are called.  But you have to move
  137. your hand from the keyboard and grab the mouse.
  138.    Menus can often be selected with keys as well.  This depends on your
  139. system, but most often it works this way.  Use the <Alt> key in combination
  140. with the underlined letter of a menu.  For example, <A-w> (<Alt> and w) pops
  141. up the Window menu.
  142.    In the Window menu, the "split" item has the p underlined.  To select it,
  143. let go of the <Alt> key and press p.
  144.  
  145. After the first selection of a menu with the <Alt> key, you can use the cursor
  146. keys to move through the menus.  <Left> selects a submenu and <Right> closes
  147. it.  <Esc> also closes a menu.  <Enter> selects a menu item.
  148.  
  149. There is a conflict between using the <Alt> key to select menu items, and
  150. using <Alt> key combinations for mappings.  The 'winaltkeys' option tells Vim
  151. what it should do with the <Alt> key.
  152.    The default value "menu" is the smart choice: If the key combination is a
  153. menu shortcut it can't be mapped.  All other keys are available for mapping.
  154.    The value "no" doesn't use any <Alt> keys for the menus.  Thus you must use
  155. the mouse for the menus, and all <Alt> keys can be mapped.
  156.    The value "yes" means that Vim will use any <Alt> keys for the menus.  Some
  157. <Alt> key combinations may also do other things than selecting a menu.
  158.  
  159. ==============================================================================
  160. *31.4*    Vim window position and size
  161.  
  162. To see the current Vim window position on the screen use: >
  163.  
  164.     :winpos
  165.  
  166. This will only work in the GUI.  The output may look like this:
  167.  
  168.     Window position: X 272, Y 103 ~
  169.  
  170. The position is given in screen pixels.  Now you can use the numbers to move
  171. Vim somewhere else.  For example, to move it to the left a hundred pixels: >
  172.  
  173.     :winpos 172 103
  174. <
  175.     Note:
  176.     There may be a small offset between the reported position and where
  177.     the window moves.  This is because of the border around the window.
  178.     This is added by the window manager.
  179.  
  180. You can use this command in your startup script to position the window at a
  181. specific position.
  182.  
  183. The size of the Vim window is computed in characters.  Thus this depends on
  184. the size of the font being used.  You can see the current size with this
  185. command: >
  186.  
  187.     :set lines columns
  188.  
  189. To change the size set the 'lines' and/or 'columns' options to a new value: >
  190.  
  191.     :set lines=50
  192.     :set columns=80
  193.  
  194. Obtaining the size works in a terminal just like in the GUI.  Setting the size
  195. is not possible in most terminals.
  196.  
  197. You can start the X-Windows version of gvim with an argument to specify the
  198. size and position of the window: >
  199.  
  200.     gvim -geometry {width}x{height}+{x_offset}+{y_offset}
  201.  
  202. {width} and {height} are in characters, {x_offset} and {y_offset} are in
  203. pixels.  Example: >
  204.  
  205.     gvim -geometry 80x25+100+300
  206.  
  207. ==============================================================================
  208. *31.5*    Various
  209.  
  210. You can use gvim to edit an e-mail message.  In your e-mail program you must
  211. select gvim to be the editor for messages.  When you try that, you will
  212. see that it doesn't work: The mail program thinks that editing is finished,
  213. while gvim is still running!
  214.    What happens is that gvim disconnects from the shell it was started in.
  215. That is fine when you start gvim in a terminal, so that you can do other work
  216. in that terminal.  But when you really want to wait for gvim to finish, you
  217. must prevent it from disconnecting.  The "-f" argument does this: >
  218.  
  219.     gvim -f file.txt
  220.  
  221. The "-f" stands for foreground.  Now Vim will block the shell it was started
  222. in until you finish editing and exit.
  223.  
  224.  
  225. DELAYED START OF THE GUI
  226.  
  227. On Unix it's possible to first start Vim in a terminal.  That's useful if you
  228. do various tasks in the same shell.  If you are editing a file and decide you
  229. want to use the GUI after all, you can start it with: >
  230.  
  231.     :gui
  232.  
  233. Vim will open the GUI window and no longer use the terminal.  You can continue
  234. using the terminal for something else.  The "-f" argument is used here to run
  235. the GUI in the foreground.  You can also use ":gui -f".
  236.  
  237.  
  238. THE GVIM STARTUP FILE
  239.  
  240. When gvim starts, it reads the gvimrc file.  That's similar to the vimrc file
  241. used when starting Vim.  The gvimrc file can be used for settings and commands
  242. that are only to be used when the GUI is going to be started.  For example,
  243. you can set the 'lines' variable to set a different window size: >
  244.  
  245.     :set lines=55
  246.  
  247. You don't want to do this in a terminal, since it's size is fixed (except for
  248. an xterm that supports resizing).
  249.    The gvimrc file is searched for in the same locations as the vimrc file.
  250. Normally it's name is "~/.gvimrc" for Unix and "$VIM/_gvimrc" for MS-Windows.
  251.    If for some reason you don't want to use the normal gvimrc file, you can
  252. specify another one with the "-U" argument: >
  253.  
  254.     gvim -U thisrc ...
  255.  
  256. That allows starting gvim for different kinds of editing.  You could set
  257. another font size, for example.
  258.    To completely skip reading a gvimrc file: >
  259.  
  260.     gvim -U NONE ...
  261.  
  262. ==============================================================================
  263.  
  264. Next chapter: |usr_40.txt|  Make new commands
  265.  
  266. Copyright: see |manual-copyright|  vim:tw=78:ts=8:ft=help:norl:
  267.